package com.fch.sdlibrary.controller;

import com.fch.sdlibrary.api.BaseResponse;
import com.fch.sdlibrary.entity.BookClazz;
import com.fch.sdlibrary.service.BookClazzService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @program: sdlibrarySpring
 * @description: 图书控制类
 * @CreatedBy: fch
 * @create: 2022-05-04 19:50
 **/
@CrossOrigin
@RestController
public class BookClazzController {
    private BaseResponse baseResponse;
    @Autowired
    private BookClazzService bookClazzService;

    @GetMapping("/QueryL1")
    public BaseResponse queryBookClassL1() {
        baseResponse = new BaseResponse();
        List<BookClazz> bookL1 = bookClazzService.queryL1();
        baseResponse.setCode(200);
        baseResponse.setData(bookL1);
        return baseResponse;
    }

    @GetMapping("/QueryL2")
    public BaseResponse queryBookClassL2(@RequestParam(value = "L1", defaultValue = "-1") String bookCode) {
        baseResponse = new BaseResponse();
        List<BookClazz> bookL2 = bookClazzService.queryL2(bookCode);
        baseResponse.setCode(200);
        baseResponse.setData(bookL2);
        return baseResponse;
    }

    @GetMapping("/QueryL3")
    public BaseResponse queryBookClassL3(@RequestParam(value = "L2", defaultValue = "-1") String bookCode) {
        baseResponse = new BaseResponse();
        List<BookClazz> bookL3 = bookClazzService.queryL3(bookCode);
        baseResponse.setCode(200);
        baseResponse.setData(bookL3);
        return baseResponse;
    }
}
